﻿namespace Management.Domain.IRepository;

public interface IRepository<TEntity> where TEntity : class, new()
{
    //TODO: Query使用Dapper ,Get 使用Dapper Contrib
    #region 查询

    /// <summary>
    /// 根据id查询一个实体
    /// </summary>
    /// <param name="id">id</param>
    /// <returns></returns>
    TEntity GetById(int id);

    /// <summary>
    /// 根据sql获取第一个或默认结果
    /// </summary>
    /// <param name="sql"></param>
    /// <param name="param"></param>
    /// <returns></returns>
    TEntity QueryFirstOrDefault(string sql, object param);

    /// <summary>
    ///  根据sql获取列表
    /// </summary>
    /// <param name="sql"></param>
    /// <param name="param"></param>
    /// <returns></returns>
    IEnumerable<TEntity> Query(string sql, object param);

    #endregion
}